package services

import (
	"context"
	"github.com/golang/protobuf/ptypes/empty"
	"kop/pb"

	rankingC "kop/modules/ranking/client"
)

func (*ConnectService) RedPoint(ctx context.Context, req *empty.Empty) (*pb.RedPointReply, error) {

	var reply pb.RedPointReply
	reply.Rankings = make(map[int32]bool, 4)

	var type1 = int32(pb.RankingType_RankingIncome)
	var type2 = int32(pb.RankingType_RankingPower)
	var type3 = int32(pb.RankingType_RankingStage)
	var type4 = int32(pb.RankingType_RankingIntimacy)

	reply.Rankings[type1] = rankingC.IsWorship(ctx, type1)
	reply.Rankings[type2] = rankingC.IsWorship(ctx, type2)
	reply.Rankings[type3] = rankingC.IsWorship(ctx, type3)
	reply.Rankings[type4] = rankingC.IsWorship(ctx, type4)

	if res, err := rankingC.RankingService.IsWorshipKing(ctx, req); err != nil {
		return &reply, err
	} else {
		reply.Kings = res.Value
	}

	return &reply, nil
}
